<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //创建一个数组
        var arr = new Array(10,20,30,40,50);  
        var arr1 = [1,2,3,4,5]; 
        console.log(arr1);
        console.log("arr1的长度="+arr1.length);
        console.log("arr1[1]="+arr1[1]);
        console.log(typeof arr1);
        console.log(arr);
        console.log("arr1的长度="+arr.length);
        console.log("arr[1]="+arr[1]);

        //创建一个数组中只有一个元素11
        var arr2 = [11];
        console.log("arr2的长度为"+arr2.length+"其值为："+arr2);
        //创建一个长度为11的数组
        var arr3 = new Array(11);
        console.log("arr3的长度为"+arr3.length+"其值为："+arr3);
   
        //数组中的元素可以是任意的数据类型
        var arr4 = ["hello",1,true,null,undefined];
        console.log(arr4);

        var obj = {
            name:"张山",
            age:20,
            sayName:function(){
                //alert(this.name);
                console.log(this.name);
            }
        };
        var obj2 = {
            name:"武大郎",
            age:50,
            sayName:function(){
                //alert(this.name+"打老虎");
                console.log(this.name+"打老虎");
            }
        }
        //创建数组arr5
        var arr5=new Array(5);
        arr5[0]="第一元素";
        arr5[1]=obj;//放入对象
        arr5[2]=obj2; 
        arr5[3]=function(){console.log("arr5第四元素方法");}
        arr5[4]=[1,2,3]

        console.log(arr5);
        console.log(arr5[2].name);
        //调用数组中的函数
        arr5[1].sayName();
        arr5[2].sayName();
        arr5[3]();
        console.log("数组中的数组"+arr5[4]);

        //-----------------------------------------------------------------------------------------
        
   </script>
</body>
</html>